<template>
  <star-horse-dialog :visible = "viewVisible" :title = "'查看数据'" :is-view = "true">
    <div class = "item">
      <label>操作人:</label>
      <div class = "content">{{ ruleForm.operator }}</div>
    </div>
    <div class = "item">
      <label>接口签名:</label>
      <div class = "content">{{ ruleForm.signature }}</div>
    </div>
    <div class = "item">
      <label>请求地址:</label>
      <div class = "content">{{ ruleForm.url }}</div>
    </div>
    <div class = "item">
      <label>请求方式:</label>
      <div class = "content">{{ ruleForm.requestMethod }}</div>
    </div>
    <div class = "item">
      <label>请求方法:</label>
      <div class = "content">{{ ruleForm.remark }}</div>
    </div>
    <div class = "item">
      <label>操作内容:</label>
      <div class = "content">{{ ruleForm.operContent }}</div>
    </div>
    <div class = "item">
      <label>状态名称:</label>
      <div class = "content">{{ ruleForm.statusName }}</div>
    </div>
    <div class = "item">
      <label>创建人:</label>
      <div class = "content">{{ ruleForm.createdBy }}</div>
    </div>
    <div class = "item">
      <label>创建日期:</label>
      <div class = "content">{{ createDate(ruleForm.createdDate) }}</div>
    </div>
  </star-horse-dialog>
  <el-card class = "inner_content">
    <!--查询区域-->
    <el-form class = "search_area" size = "default">
      <el-form-item label = "操作人">
        <el-input placeholder = "请输入操作人" v-model = "searchForm.operator"/>
      </el-form-item>
      <el-form-item label = "接口名称">
        <el-input placeholder = "请输入接口名称" v-model = "searchForm.signature"/>
      </el-form-item>
      <el-form-item label = "生成时间">
        <el-date-picker
            value-format = "YYYY-MM-DD"
            end-placeholder = "结束日期" placeholder = "请选择添加时间"
            range-separator = "到"
            start-placeholder = "开始日期"
            type = "daterange"
            v-model = "searchForm.createdDate"
        />
      </el-form-item>
      <el-form-item label = "     ">
        <el-button @click = "dataSearch" link type = "primary">
          <user-icon icon = "search"/>
          <span style = "vertical-align: middle;"> 查询 </span>
        </el-button>
        <el-button @click = "dataSearch(1)" link small>
          <span style = "vertical-align: middle;"> 重置 </span>
        </el-button>
      </el-form-item>
    </el-form>
    <el-divider/>
    <!--        <ul class="inner_button">
                <li v-if="permission.add">
                    <el-button @click="btnOperation(1)" link title="" type="primary">
                        <user-icon icon="plus" />
                        <el-tooltip content="新增">新增</el-tooltip>
                    </el-button>
                </li>
                 <li v-if="permission.batchAdd">
                      <el-button @click="btnOperation(11)" title=""  type="primary" link>
                          <user-icon icon="plus-square" />
                           <el-tooltip content="批量新增">批量新增</el-tooltip>
                      </el-button>
                  </li>
                <li v-if="permission.edit">
                    <el-button @click="btnOperation(2)" link title="" type="primary">
                        <user-icon icon="edit" />
                        <el-tooltip content="编辑">编辑</el-tooltip>
                    </el-button>
                </li>
                <li v-if="permission.view">
                    <el-button @click="btnOperation(3)" link title="" type="primary">
                        <user-icon icon="book-open" />
                        <el-tooltip content="查看">查看</el-tooltip>
                    </el-button>
                </li>
                <li v-if="permission.delete">
                    <el-button @click="btnOperation(4)" link title="" type="danger">
                        <user-icon icon="minus-square" />
                        <el-tooltip content="删除">删除</el-tooltip>
                    </el-button>
                </li>
                <li v-if="permission.view">
                    <el-button @click="btnOperation(5)" link title="" type="primary">
                        <user-icon icon="sync" />
                        <el-tooltip content="刷新">刷新</el-tooltip>

                    </el-button>
                </li>
                <li v-if="permission.download">
                    <el-button @click="btnOperation(6)" link title="" type="primary">
                        <user-icon icon="file-download" />
                        <el-tooltip content="下载模板">下载模板</el-tooltip>
                    </el-button>
                </li>
                <li v-if="permission.execution">
                    <el-button @click="btnOperation(7)" link title="" type="primary">
                        <user-icon icon="play-circle" />
                        <el-tooltip content="执行">执行</el-tooltip>
                    </el-button>
                </li>
                <li v-if="permission.upload">
                    <el-upload
                            :auto-upload="true"
                            :on-change="upload"
                            :on-error="uploadError"
                            :on-progress="uploadProcess"
                            :on-success="uploadSuccess"
                            :show-file-list="false"
                            action="/system-config/system/auditEntity/importData"
                            :headers="uploadHeaders"
                            class="upload-demo"
                            name="file"
                    >
                        <el-button link title="" type="primary">
                            <user-icon icon="file-upload" />
                            <el-tooltip content="上传">上传</el-tooltip>
                        </el-button>

                    </el-upload>
                </li>
                <li v-if="permission.export">
                    <el-button @click="btnOperation(8)" link title="" type="primary">
                        <user-icon icon="file-export" />
                        <el-tooltip content="导出">导出</el-tooltip>
                    </el-button>
                </li>
            </ul>-->
    <el-table
        :data = "dataList"
        :fit = "true"
        :highlight-current-row = "true"
        :row-key = "getRowIdentity"
        @row-dblclick = "editData"
        @selection-change = "handleSelectionChange"
        border
        class = "data_table"
        id = "auditPo"
        ref = "multipleTable"
        stripe = "true">
      <el-table-column fixed width = "1"/>
      <el-table-column
          :reserve-selection = "true"
          align = "center"
          fixed = "left"
          type = "selection"
      />
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "主键"
          min-width = "200px"
          prop = "idAudit"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "操作人"
          min-width = "200px"
          prop = "operator"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "签名"
          min-width = "200px"
          prop = "signature"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "请求地址"
          min-width = "200px"
          prop = "url"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "请求方法"
          min-width = "200px"
          prop = "remark"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "请求方式"
          min-width = "200px"
          prop = "requestMethod"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "参数"
          min-width = "200px"
          prop = "operContent"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "修改人"
          min-width = "200px"
          prop = "updatedBy"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "修改日期"
          min-width = "200px"
          prop = "updatedDate"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "操作人"
          min-width = "200px"
          prop = "createdBy"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "创建日期"
          min-width = "200px"
          prop = "createdDate"
          sortable
          v-if = " true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "是否删除 1 是 0否"
          min-width = "200px"
          prop = "isDel"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "状态名称"
          min-width = "200px"
          prop = "statusName"
          sortable
          v-if = "false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "状态编码"
          min-width = "200px"
          prop = "statusCode"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column fixed = "right" label = "操作" min-width = "80px">
        <template #default = "scope">
          <!--                    <el-button v-if="permission.edit" @click="editById(scope.row[primaryKey])" link title=""
                                         type="primary">
                                  <el-tooltip content="编辑">编辑</el-tooltip>
                              </el-button>-->
          <el-button v-if = "permission.view" @click = "viewById(scope.row[primaryKey])" link title = ""
                     type = "primary">
            <el-tooltip content = "查看">查看</el-tooltip>
          </el-button>
          <!--                    <el-button v-if="permission.delete" @click="deleteById(scope.row[primaryKey])" link title=""
                                         type="danger">
                                  <el-tooltip content="删除">删除</el-tooltip>
                              </el-button>-->
        </template>
      </el-table-column>
    </el-table>
    <el-divider/>
    <el-pagination
        :total = "totalData"
        @current-change = "pageChangeClick"
        @size-change = "pageSizeClick"
        layout = "total, sizes, prev, pager, next, jumper"
        v-model:currentPage = "currentPage"
        v-model:page-size = "pageSize"
        v-model:pageCount = "totalPage"
    />
  </el-card>
</template>
<style lang = "scss" scoped>
.el-card {
}

.data_table {
  height: 400px;
}
</style>
<script>

import {common} from "../../api/common";
import {ref} from "vue";

export default {
  name: "AuditEntity",
  
  mixins: [common],
  setup() {
    return {}
  },
  data() {
    const loadByPageUrl = ref("/system-config/system/auditEntity/pageList");
    const mergeUrl = ref("/system-config/system/auditEntity/merge");
    const mergeDraftUrl = ref("/system-config/system/auditEntity/mergeDraft");
    const batchMergeUrl = ref("/system-config/system/auditEntity/mergeBatch");
    const batchMergeDraftUrl = ref("/system-config/system/auditEntity/mergeBatchDraft");
    const loadByIdUrl = ref("/system-config/system/auditEntity/getById");
    const deleteUrl = ref("/system-config/system/auditEntity/batchDeleteById");
    const exportAllUrl = ref("/system-config/system/auditEntity/exportData");
    const downloadTemplateUrl = ref("/system-config/system/auditEntity/downloadTemplate");
    const primaryKey = "idAudit";
    return {
      loadByPageUrl,
      mergeUrl,
      mergeDraftUrl,
      batchMergeUrl,
      batchMergeDraftUrl,
      loadByIdUrl,
      deleteUrl,
      exportAllUrl,
      downloadTemplateUrl,
      primaryKey
    }
  },
  methods: {
    dataFormat(row, column, cellValue, index) {
      cellValue = this.commonDataFormat(row, column, cellValue, index);
      return cellValue;
    },

    /**
     * 初始化数据
     */
    init: function () {
      this.dataList = [];
      this.selectData = [];
      this.loadByPage(this.currentPage, this.pageSize);
      this.loadPermissionResources();
      this.loadSelectData();

    },

    /**
     * 状态码数据
     */
    loadSelectData() {
      let that = this;
      that.commonSelectData("sys_audit");
    }
    ,

    parseSearchData: function () {
      let data = this.searchForm;
      let arr = [];
      if (data.operator) {
        arr.push({
          propertyName: "operator",
          value: data.operator,
          operation: "lk"
        });
      }
      if (data.signature) {
        arr.push({
          propertyName: "signature",
          value: data.signature,
          operation: "lk"
        });
      }
      if (data.createdDate) {

        arr.push({
          propertyName: "createdDate",
          value: [data.createdDate[0] + " 00:00:00", data.createdDate[1] + " 23:59:59"],
          operation: "bt"
        });
      }
      return arr;
    }

  },
  created() {
    this.init();
  }
}
</script>